<?php

include '../helpers/application.php';
include '../helpers/dbhelper.php';
include '../helpers/userhelper.php';

$app = new Application();
$id = $_GET["id"];
$app->db->query("SELECT name, vorname FROM dozent  WHERE dozentid=".$id."",1);
$result=$app->db->fetch(1);
$app->db->query("SELECT  s.status, dh.datum,dh.kommentar, u.username FROM status s, dozent d, dozentenhistorie dh, user u WHERE d.dozentid = ".$id." and dh.status=s.statusid and d.dozentid = dh.dozentid and dh.userid = u.userid",2);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--?xml version="1.0" encoding="utf-8"?-->
<html xml:lang="de" xmlns="http://www.w3.org/1999/xhtml" lang="de">
<head>
<title>Historie</title>
<link rel="stylesheet" type="text/css" href="../media/css/popup.css"
	media="all" />
<link rel="shortcut icon" href="../media/images/favicon.ico" type="image/x-icon" />
<link rel="icon" href="../media/images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="../media/js/jquery.js"></script>
</head>
<body>
	<div id="header">
		<h1>Historie</h1>
		<p><?php echo $result['vorname']." ".$result['name']?></p>
	</div>
	<div id="container">
	<?php 
	foreach ($app->db->tpl_fetch(2) as $line) {
	echo '<div class="date">'.date("d.m.Y H:i", strToTime($line['datum'])).'</div>
		<table class="info">
			<tr>
				<td class="status">'.$line['status'].'</td>
				<td class="user">'.$line['username'].'</td>
			</tr>';
	if(!empty($line['kommentar'])) {
			echo '<tr>
				<td colspan="2" class="comment">'.$line['kommentar'].'</td>
			</tr>';
	}
		echo '</table>';
	}
	
	?>
	</div>
</body>
</html>
